maintainer="Natanael Copa <ncopa@alpinelinux.org>"
pkgname=debian-devscripts
pkgver=2.24.1
pkgrel=0
pkgdesc="debian developer scripts"
url="https://tracker.debian.org/pkg/devscripts"
arch="noarch"
license="GPL-2.0-or-later"
checkdepends="perl"
# checkbashisms is the common accepted name, but prefix for rest
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	checkbashisms
	$pkgname-hardening-check:harden
	"
source="https://ftp.debian.org/debian/pool/main/d/devscripts/devscripts_$pkgver.tar.xz"
builddir="$srcdir"/devscripts-$pkgver/scripts

prepare() {
	default_prepare

	sed -i "s/###VERSION###/$pkgver/" checkbashisms.pl

	mv checkbashisms.pl checkbashisms
	mv hardening-check.pl hardening-check
}

check() {
	printf '#!/bin/sh\necho "hello world"\n' > ./testfile
	perl ./checkbashisms --version
	perl ./checkbashisms ./testfile
}

package() {
	depends="
		checkbashisms=$pkgver-r$pkgrel
		$pkgname-hardening-check=$pkgver-r$pkgrel
		"

	# only these useful for now
	install -Dm755 -t "$pkgdir"/usr/bin/ \
		checkbashisms \
		hardening-check

	install -Dm644 checkbashisms.1 \
		-t "$pkgdir"/usr/share/man/man1/
	install -Dm644 checkbashisms.bash_completion \
		$pkgdir/usr/share/bash-completion/completions/checkbashisms
}

checkbashisms() {
	pkgdesc="$pkgdesc (checkbashisms)"
	depends="perl"

	amove usr/bin/checkbashisms
}

harden() {
	pkgdesc="$pkgdesc (hardening-check)"
	depends="perl"

	amove usr/bin/hardening-check
}

sha512sums="
fa87b6bff7cb449b914b6ee66822a1bdb01926da26af998938ade967ba60e09f5c6476815f7961bd145e849c647da838607ca86b664c804b863367941466ed24  devscripts_2.24.1.tar.xz
"
